package com.lagou.dubbo;

import com.lagou.code.CodeDubboService;
import com.lagou.po.CodePO;
import com.lagou.service.CodeService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @AUTHOR: yb.feng
 * @DATE: 2020/7/1 20:33
 * @DESC:
 */
@Service
public class CodeDubboDubboImpl implements CodeDubboService {

    @Autowired
    private CodeService codeService;

    @Override
    public Integer validateCode(@PathVariable String email, @PathVariable String code){
        CodePO realCode = codeService.getCode(email);
        if (realCode.getExpiretime().getTime() < System.currentTimeMillis()){
            return 2;
        }
        if (!code.equals(realCode.getCode())){
            return 1;
        }
        return 0;
    }
}
